package cn.laixueit.service.impl;

import cn.laixueit.mapper.CategoryMapper;
import cn.laixueit.pojo.Category;
import cn.laixueit.service.CategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {
    @Override
    public List<Category> listByPid(Long pid) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("parent_id",pid);
        List<Category> categoryList = listByMap(map).stream().collect(Collectors.toList());
        return categoryList;
    }

    @Override
    public   List<Category> findCnameByList(List<Long> cids) {
        List<Category> categoryList = listByIds(cids).stream().collect(Collectors.toList());
        return categoryList;
    }
}
